package com.zero.manage.web.components.dto;

import io.gitee.zerowsh.enums.ToolEnums;
import com.zero.manage.web.utils.validated.GenGroupSequenceProvider;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.group.GroupSequenceProvider;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

@Data
@ApiModel("代码生成参数")
@GroupSequenceProvider(GenGroupSequenceProvider.class)
public class GenDto {
    @ApiModelProperty("数据库名称")
    @NotBlank(message = "数据库名称必填")
    private String catalog;

    @ApiModelProperty("表信息")
    @NotNull(message = "表信息必填")
    private List<TableAndComment> tableInfo;

    @ApiModelProperty("实体基类")
    @NotNull(message = "实体基类必填")
    private ToolEnums.BaseEntityEnums baseEntity;

    @ApiModelProperty("数据库管理编号")
    @NotBlank(message = "数据库管理编号必填")
    private String databaseInfoId;

    @ApiModelProperty("生成代码文件的基本路径")
    @NotBlank(groups = BasicPathPathGroup.class, message = "文件路径必填")
    private String basicPath;

    @ApiModelProperty("生成包路径")
    @NotBlank(message = "生成包路径必填")
    private String packagePath;

    @ApiModelProperty("作者")
    @NotBlank(message = "作者必填")
    private String author;

    @ApiModelProperty("是否下载")
    private ToolEnums.WhetherEnums download = ToolEnums.WhetherEnums.T;

    @ApiModelProperty("表前缀(生成文件时忽略的表前缀)")
    private String tablePrefix;

    /**
     * 定义专属的业务逻辑分组
     */
    public interface BasicPathPathGroup {
    }

    /**
     * 表名称和备注
     */
    @Getter
    @Setter
    public static class TableAndComment {
        private String tableName;
        private String tableComment;
    }
}
